args=commandArgs(T)
sampleName <- args[1]
CellTypeStr<- args[2]
workdir <- args[3]
seuratData <- args[4]

#finish in 2021.2.22

print("load data:")
load(seuratData)
print("Cell Type:")
CellType=unlist(strsplit(CellTypeStr,split=","))
print(CellType)
print("set workdir:")
setwd(workdir)
print(workdir)


CellTypeDisPlot <- function(sample,CellType)
{
  
  allcells <- rownames(all10x.Seurat@reductions$tsne@cell.embeddings)
  for(i in CellType)
  {
    print(i)
    ChoCellType <- allcells[grep(i,allcells)]
    CellPlotFile <- paste(sample,".",i,".png",sep="")
    png(CellPlotFile,width=800,height=500)

    p <- plot(all10x.Seurat@reductions$tsne@cell.embeddings,pch=".",col="grey",cex=0.2,main=i)
    p <- points(all10x.Seurat@reductions$tsne@cell.embeddings[ChoCellType,],col="red",pch=".",cex=2)
    print(p)

    dev.off()
  }
}

CellTypeDisPlot(sampleName,CellType)
